home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ShapeBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  206 lines

  1. package symantec.itools.awt.shape;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Removed font as property (Addresses Mac Bug #7687).
  8.  
  9. /**
  10.  * BeanInfo for Shape.
  11.  *
  12.  */
  13. public class ShapeBeanInfo extends SimpleBeanInfo {
  14.  
  15.     /**
  16.      * Constructs a ShapeBeanInfo object.
  17.      */
  18.     public ShapeBeanInfo() {
  19.     }
  20.  
  21.     /**
  22.      * Gets a BeanInfo for the superclass of this bean.
  23.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  24.      */
  25.     public BeanInfo[] getAdditionalBeanInfo() {
  26.         try {
  27.             BeanInfo[] bi = new BeanInfo[1];
  28.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  29.             return bi;
  30.         }
  31.         catch (IntrospectionException e) { throw new Error(e.toString());}
  32.     }
  33.  
  34.     /**
  35.      * Gets the SymantecBeanDescriptor for this bean.
  36.      * @return an object of type SymantecBeanDescriptor
  37.      * @see symantec.itools.beans.SymantecBeanDescriptor
  38.      */
  39.     public BeanDescriptor getBeanDescriptor() {
  40.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  41.  
  42.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  43.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  44.                                                 "%name%.BEVEL_LOWERED",
  45.                                                 conn.getString("BEVEL_LOWERED")));
  46.  
  47.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  48.                                                 "%name%.BEVEL_RAISED",
  49.                                                 conn.getString("BEVEL_RAISED")));
  50.  
  51.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  52.                                                 "%name%.BEVEL_LINE",
  53.                                                 conn.getString("BEVEL_LINE")));
  54.  
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  56.                                                 "%name%.BEVEL_NONE",
  57.                                                 conn.getString("BEVEL_NONE")));
  58.  
  59.         return (BeanDescriptor) bd;
  60.     }
  61.  
  62.     /**
  63.      * Gets an array of descriptions of the methods used for "connections" by
  64.      * Visual CafΘ's Interaction Wizard.
  65.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  66.      * @return method descriptions for this bean
  67.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  68.      */
  69.     public MethodDescriptor[] getMethodDescriptors() {
  70.         Class[] args;
  71.         ConnectionDescriptor connection;
  72.         java.util.Vector connections;
  73.         java.util.Vector md = new java.util.Vector();
  74.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  75.  
  76.         try{
  77.             args = new Class[1];
  78.             args[0] = java.lang.Boolean.TYPE ;
  79.             MethodDescriptor setFillMode = new MethodDescriptor(beanClass.getMethod("setFillMode", args));
  80.  
  81.             connections = new java.util.Vector();
  82.             connection = new ConnectionDescriptor("input", "boolean", "",
  83.                                     "%name%.setFillMode(%arg%);",
  84.                                     conn.getString("setFillMode"));
  85.             connections.addElement(connection);
  86.  
  87.             setFillMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  88.             md.addElement(setFillMode);
  89.         } catch (Exception e) { throw new Error("setFillMode:: " + e.toString()); }
  90.  
  91.         try{
  92.             args = null;
  93.             MethodDescriptor getBevelStyle = new MethodDescriptor(beanClass.getMethod("getBevelStyle", args));
  94.  
  95.             connections = new java.util.Vector();
  96.             connection = new ConnectionDescriptor("output", "int", "",
  97.                                     "%name%.getBevelStyle()",
  98.                                     conn.getString("getBevelStyle"));
  99.             connections.addElement(connection);
  100.  
  101.             getBevelStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  102.             md.addElement(getBevelStyle);
  103.         } catch (Exception e) { throw new Error("getBevelStyle:: " + e.toString()); }
  104.  
  105.         try{
  106.             args = null;
  107.             MethodDescriptor isFillMode = new MethodDescriptor(beanClass.getMethod("isFillMode", args));
  108.  
  109.             connections = new java.util.Vector();
  110.             connection = new ConnectionDescriptor("output", "boolean", "",
  111.                                     "%name%.isFillMode()",
  112.                                     conn.getString("isFillMode"));
  113.             connections.addElement(connection);
  114.  
  115.             isFillMode.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  116.             md.addElement(isFillMode);
  117.         } catch (Exception e) { throw new Error("isFillMode:: " + e.toString()); }
  118.  
  119.         try{
  120.             args = null;
  121.             MethodDescriptor getFillColor = new MethodDescriptor(beanClass.getMethod("getFillColor", args));
  122.  
  123.             connections = new java.util.Vector();
  124.             connection = new ConnectionDescriptor("output", "Color", "",
  125.                                     "%name%.getFillColor()",
  126.                                     conn.getString("getFillColor"));
  127.             connections.addElement(connection);
  128.  
  129.             getFillColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  130.             md.addElement(getFillColor);
  131.         } catch (Exception e) { throw new Error("getFillColor:: " + e.toString()); }
  132.  
  133.         try{
  134.             args = new Class[1];
  135.             args[0] = java.lang.Integer.TYPE ;
  136.             MethodDescriptor setBevelStyle = new MethodDescriptor(beanClass.getMethod("setBevelStyle", args));
  137.  
  138.             connections = new java.util.Vector();
  139.             connection = new ConnectionDescriptor("input", "int", "",
  140.                                     "%name%.setBevelStyle(%arg%);",
  141.                                     conn.getString("setBevelStyle"));
  142.             connections.addElement(connection);
  143.  
  144.             setBevelStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  145.             md.addElement(setBevelStyle);
  146.         } catch (Exception e) { throw new Error("setBevelStyle:: " + e.toString()); }
  147.  
  148.         try{
  149.             args = new Class[1];
  150.             args[0] = java.awt.Color.class ;
  151.             MethodDescriptor setFillColor = new MethodDescriptor(beanClass.getMethod("setFillColor", args));
  152.  
  153.             connections = new java.util.Vector();
  154.             connection = new ConnectionDescriptor("input", "Color", "",
  155.                                     "%name%.setFillColor(%arg%);",
  156.                                     conn.getString("setFillColor"));
  157.             connections.addElement(connection);
  158.  
  159.             setFillColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  160.             md.addElement(setFillColor);
  161.         } catch (Exception e) { throw new Error("setFillColor:: " + e.toString()); }
  162.  
  163.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  164.         md.copyInto(rv);
  165.  
  166.         return rv;
  167.     }
  168.  
  169.     /**
  170.      * Returns descriptions of this bean's properties.
  171.      */
  172.     public PropertyDescriptor[] getPropertyDescriptors() {
  173.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  174.  
  175.         try{
  176.         PropertyDescriptor bevelStyle = new PropertyDescriptor("bevelStyle", beanClass);
  177.         bevelStyle.setBound(true);
  178.         bevelStyle.setConstrained(true);
  179.         bevelStyle.setDisplayName(prop.getString("bevelStyle"));
  180.         bevelStyle.setValue("ENUMERATION", "BEVEL_LOWERED=0, BEVEL_RAISED=1, BEVEL_LINE=2, BEVEL_NONE=3");
  181.  
  182.         PropertyDescriptor fillMode = new PropertyDescriptor("fillMode", beanClass);
  183.         fillMode.setBound(true);
  184.         fillMode.setConstrained(true);
  185.         fillMode.setDisplayName(prop.getString("fillMode"));
  186.  
  187.         PropertyDescriptor fillColor = new PropertyDescriptor("fillColor", beanClass);
  188.         fillColor.setBound(true);
  189.         fillColor.setConstrained(true);
  190.         fillColor.setDisplayName(prop.getString("fillColor"));
  191.  
  192.         PropertyDescriptor font = new PropertyDescriptor("font", beanClass);
  193.         font.setHidden(true);
  194.  
  195.         PropertyDescriptor[] rv = {
  196.             bevelStyle,
  197.             fillMode,
  198.             fillColor,
  199.             font};
  200.         return rv;
  201.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  202.     }
  203.  
  204.     private final static Class beanClass = Shape.class;
  205.  
  206.     }    //  end of class ShapeBeanInfo